<!--
 * @Date: 2020-09-21 17:29:40
 * @LastEditors: 小枫
 * @LastEditTime: 2020-09-25 20:31:34
 * @FilePath: \feng-blog-admin\src\views\ManageUsers.vue
-->
<template lang="pug">
  .manage-user
    el-table(:data='users', style='width: 100%')
      el-table-column(label='ID')
        template(slot-scope='scope') {{ scope.row.uid }}
      el-table-column(label='用户名')
        template(slot-scope='scope') {{ scope.row.username }}
    el-pagination(
      background,
      :pager-count="11",
      :current-page="page",
      layout="prev, pager, next",
      :page-count="allPage",
      @current-change="handleCurrentChange"
      )
</template>

<script>
export default {
  data () {
    return {
      users: [],
      allPage: null,
      page: 1
    }
  },
  methods: {
    handleCurrentChange (val) {
      this.page = val
      this.getAllArticle()
    },
    getAllUsers () {
      this.$http.get('/users').then(
        res => {
          if (res) {
            this.allPage = res.data.data.allPage
            this.users = res.data.data.userList
          }
        }
      )
    }
  },
  created () {
    this.getAllUsers()
  }
}
</script>

<style lang="less" scoped>

</style>
